import ray
import time

start_time = time.time()


def slow_function_1(t):
    time.sleep(t)
    return t


@ray.remote(num_cpus=4)
def slow_function_2(t):
    time.sleep(t)
    return t


t1 = time.time()
results = [slow_function_1(i) for i in range(5)]
t2 = time.time()
duration = t2 - t1
print('The results are {}. This took {} seconds'.format(results, duration))

t1 = time.time()
results = [slow_function_2.remote(i) for i in range(5)]
t2 = time.time()
duration = t2 - t1
print('The results are {}. This took {} seconds'.format(results, duration))
